<?php
$id=$_GET['uid'];
$muser=new Model_User;
if(isset($_POST['ok'])){
	if($_POST['txtuser'] == NULL){
		$data['error'][]=ERROR_USER_EMPTY;
	}else{
		$u=$_POST['txtuser'];
	}
	if($_POST['txtpass'] != $_POST['txtpass2']){
		$data['error'][]=ERROR_PASS_MATCHES;
	}else{
		if($_POST['txtpass'] != NULL){
			$p=$_POST['txtpass'];	
		}else{
			$p="none";
		}
	}
	$l=$_POST['level'];
	if($u && $p && $l){
		$data=array(
			"username" => $u,
			"level"    => $l
		);
		if($p != "none"){
			$data['password'] = $p;
		}
		if($muser->update_user($data,$id) == TRUE){
			redirect("index.php?module=user&act=list");
		}else{
			$data['error'][]=ERROR_USER_REGISTER;
		}
	}

}
$data['info']=$muser->getuser($id);
loadview("user/edit_view",$data);